package myzd.api.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by liuqian on 2017/9/22 17:11.
 */
public class RegexUtils {
  /**
   * 正则表达式验证字符串
   *
   * @param regex
   * @param str
   * @return
   */
  private static boolean match(String regex, String str) {
    if (null == str || "".equals(str)) {
      return false;
    } else {
      Pattern p = Pattern.compile(regex);
      Matcher m = p.matcher(str);
      return m.find();
    }
  }

  /**
   * 验证中文汉字!
   *
   * @param name
   * @return
   */
  public static boolean containsChinese(String name) {
    String regex = "[\u4e00-\u9fa5]";
    return match(regex, name);
  }
}
